using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerAirState : PlayerState
{
    public PlayerAirState(Player player, StateMachine<PlayerState> stateMachine, string animBoolName) : base(player, stateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void Update()
    {
        base.Update();
       
        if (!Mathf.Approximately(xInput, 0f))
        {
            player.SetVelocity(xInput * player.moveInAirSpeed, rb.velocity.y);
        }

        if (player.IsGroundDetected())
        {
            player.dashCounterInAir = 0;
            stateMachine.ChangeState(player.idleState);
        }

        if (player.IsWallDetected())
        {
            stateMachine.ChangeState(player.wallSlideState);
            player.dashCounterInAir = 0;
        }

        if (KeyInputManager.GetAttackKey())
        {
            stateMachine.ChangeState(player.airAttackState);
        }
    }
     
    protected override bool CheckDashInput()
    {
        if (base.CheckDashInput() && player.dashCounterInAir < player.dashNumInAir)
        {
            player.dashCounterInAir++;
            return true;

        }
        return false;
    }
}
